package com.ccys.cms.controller.consultation;

import com.ccys.cms.service.consultation.BookingQueueWebService;
import com.ccys.common.constants.ContextConstants;
import com.ccys.common.util.Kit;
import com.ccys.common.vo.ResponseResult;
import com.ccys.db.dto.consultation.BookingDTO;
import com.ccys.db.dto.consultation.BookingQueueDTO;
import com.ccys.db.entity.TblAppointmentCancellation;
import com.ccys.db.entity.TblBookingQueue;
import com.ccys.db.vo.consultation.BookingAppointmentWebVO;
import com.ccys.db.vo.consultation.BookingQueueWebVO;
import com.ccys.db.vo.consultation.CountBookingNumWebVO;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@Api(tags = "诊断与预约-问诊队列")
@RequestMapping("consultation")
public class BookingQueueWebController {

    @Autowired
    private BookingQueueWebService bookingQueueWebService;



    @GetMapping("bookingQueue")
    @ApiOperation("获取问诊对列列表")
    @ApiImplicitParams({

        @ApiImplicitParam(name = "specialisationId", value = "科室ID", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "memId", value = "病人ID", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "consultDoctorId", value = "咨询医生id", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "selectedDoctorId", value = "选择医生ID", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "groupId", value = "集团ID", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "countryId", value = "国家ID", required = false, dataType = "string", paramType = "query"),

        @ApiImplicitParam(name = "id", value = "对象id", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "startTime", value = "开始时间(格式 yyyy-mm-dd)", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "endTime", value = "结束时间(格式 yyyy-mm-dd)", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "orderByStr", value = "排序字段（后端返回的字段  asc升序，desc 降序,加上end后缀。示例（createdOn降序排 则传值 createdOn descend））",paramType = "query"),
    })
    @ApiResponses({
        @ApiResponse(code = 411, message = ContextConstants.DESC_411),
        @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC,response = BookingQueueWebVO.class)
    })
    public ResponseResult listObjectsCms(@ApiIgnore BookingQueueDTO dto) {
        return this.bookingQueueWebService.listObjectsCms(dto);
    }


    @GetMapping("bookingQueue/countBookingNum")
    @ApiOperation("统计对列国家与科室的问诊排队数量")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "memId", value = "病人ID", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "consultDoctorId", value = "咨询医生id", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "selectedDoctorId", value = "选择医生ID", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "groupId", value = "集团ID", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "countryId", value = "国家ID", required = false, dataType = "string", paramType = "query"),
    })
    @ApiResponses({
        @ApiResponse(code = 411, message = ContextConstants.DESC_411),
        @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC,response = CountBookingNumWebVO.class)
    })
    public ResponseResult countBookingNum(@ApiIgnore BookingQueueDTO dto) {
        return this.bookingQueueWebService.countBookingNum(dto);
    }


    @PutMapping("bookingQueue")
    @ApiOperation("编辑问诊对列")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "id", value = "对列ID", required = true, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "queueNo", value = "实时位置 通过group_country_specialisation分组", required = false, dataType = "string", paramType = "query"),
        //@ApiImplicitParam(name = "positionNo", value = "展示位置", required = false, dataType = "string", paramType = "query"),
    })
    @ApiResponses({
        @ApiResponse(code = 411, message = ContextConstants.DESC_411),
        @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC)
    })
    public ResponseResult edit(@ApiIgnore TblBookingQueue entity) {
        Kit.allParamValid(entity, "id");
        return this.bookingQueueWebService.change(entity);
    }
    @DeleteMapping("bookingQueue")
    @ApiOperation("删除")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "id", value = "ID号", required = true, dataType = "string", paramType = "query")
    })
    @ApiResponses({
        @ApiResponse(code = 411, message = ContextConstants.DESC_411),
        @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC)
    })
    public ResponseResult delete(@ApiIgnore BookingQueueDTO dto) {
        Kit.allParamValid(dto, "id");
        return this.bookingQueueWebService.delete(dto);
    }

}